cmake_minimum_required(VERSION 3.16)
project(socket_api)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")
# set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
# set( EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin )
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin )

find_package(Boost 1.71 REQUIRED COMPONENTS system thread date_time)

include_directories(${CMAKE_BINARY_DIR})
# 系统库头文件
include_directories(/usr/include/) 
 
# 头文件
include_directories(${PROJECT_SOURCE_DIR}/include/)
include_directories(${PROJECT_SOURCE_DIR}/src/)
include_directories(${PROJECT_SOURCE_DIR}/demo/)
# 实现文件
file(GLOB API_SRC ${PROJECT_SOURCE_DIR}/src/*.cpp)


add_library(socket_api SHARED ${API_SRC})

add_executable(demo_server demo/demo_server.cpp)
target_link_libraries(demo_server socket_api ${Boost_LIBRARIES})

add_executable(demo_client demo/demo_client.cpp)
target_link_libraries(demo_client socket_api ${Boost_LIBRARIES})

# enable_testing()
# add_subdirectory(tests)
